import java.util.HashMap;

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }

    //最长的斐波那契子序列的长度
    public int lenLongestFibSubseq(int[] arr) {
        HashMap<Integer, Integer> map = new HashMap<>();

        int n = arr.length;
        for (int i = 0; i < n; i++) {
            map.put(arr[i], i);
        }
        int[][] dp = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dp[i][j] = 2;
            }
        }
        int ret = 2;
        for (int i = 2; i < n; i++) {
            for (int j = 1; j < i; j++) {
                //获取斐波那契数列相减之后的数，并且判断是否包含在Hash表中
                int a = arr[i] - arr[j];
                if (a < arr[j] && map.containsKey(a)) {
                    dp[j][i] = dp[map.get(a)][j] + 1;
                }
                ret = Math.max(ret, dp[j][i]);
            }
        }
        //判断是否存在斐波那契数列，如果ret<3就不存在
        return ret < 3 ? 0 : ret;
    }
}